package src.itheima05;

import java.util.*;

/**
 * @author xxx
 * @date 2020/12/21 18:07
 * @description
 */
public class A {
    public static void main(String[] args) {
        //1.创建Map集合对象pokers,存储54张扑克
        Map<Integer, String> pokers = new HashMap();
        //2.创建2个List集合对象colors和nums,用来存储花色和数字
        List<String> coloer = new ArrayList<>();
        List<String> nums = new ArrayList<>();

        //3.向List集合对象colors中存储花色
        Collections.addAll(coloer, "♥", "♠", "♣", "♦");

        //4.向List集合对象nums中存储数字
        Collections.addAll(nums, "3-4-5-6-7-8-9-10-J-Q-K-A-2".split("-"));

        //5.循环嵌套遍历存储花色和数字的集合对象拼接成一张扑克牌,存到pokers中，54张牌，每张牌一个数字编号
        int index = 0;
        //1.获取存储54张扑克的Map集合的所有的键对应的Set集合
        for (String num : nums) {
            for (String s : coloer) {
                String perk = s + num;
                pokers.put(index, perk);

                index++;
            }
        }
        pokers.put(index++, "小王");
        pokers.put(index, "大王");
        //打乱发牌
        List<Integer> list = new ArrayList(pokers.keySet());
        //创建4个集合收集发牌，发牌到对应集合和亮出底牌，展示每人手中的牌
        System.out.println(list);
        Collections.shuffle(list);
        System.out.println(list);


        List<String> p1=new ArrayList();
        List<String> p2=new ArrayList();
        List<String> p3=new ArrayList();
        List<String> bootm=new ArrayList();

        for (int i = 0;i<list.size();i++) {
            String p=pokers.get(list.get(i));

            if(i>50){
                bootm.add(p);
            }else if(i %3==0){
                p1.add(p);
            }else if (i%3==1){
                p2.add(p);
            }else if (i%3==2){
                p3.add(p);
        }
    }

        System.out.println("1p:"+p1);
        System.out.println("2p:"+p2);
        System.out.println("3p:"+p3);
        System.out.println("4p:"+bootm);
    }
}